import requests

#定义请求的url
url = 'https://i.csdn.net/#/uc/profile'


#定义请求头信息
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
    'cookie': '159350162378210532068932'#这里的内容可以根据自己在登陆时查看cookie，然后直接粘贴在这里
}


#发起Get请求
res  =  requests.get(url=url,headers=headers)

#获取相应状态码，当响应状态码为200 时则表示请求成功
code = res.status_code
print(code)

if code ==200:
    with open ('cookie和session.html','w',encoding="utf-8") as fp:
        fp.write(res.text)

